Skip to content

Conversation

@KevinShook
Copy link
Contributor

Revised hydographs

Description

Added a new function ch_gg_hydrographs which obtains WSC daily and/or peak flows from tidyhydat and plots flows for one or many stations. The resulting plots can be facettted.

Related Issue

Renamed function ch_hydrograph_plot to ch_model_hydrograph, as that is what it is really intended for., and "plot" is redundant.

Example

@aszeitz
Copy link

aszeitz commented Sep 15, 2025

Hi Kevin, could you please let me know when you'd like this reviewed by so I can add it to my to-do list accordingly? Have a quickly building pile as the semester ramps up.

@KevinShook
Copy link
Contributor Author

It's not time critical. I just need someone (preferably 2 people) to check it over. It can wait until then.

@aszeitz
Copy link

aszeitz commented Oct 22, 2025

Looking over the ch_gg_hydrograph function one thing that jumped out to me is that we may want to expand the handling of the annual instantaneous peak common dates. Presently, it sets the common dates to the specific date range. Would it be more useful to show the annual instantaneous peaks per common years?

For example, if you compare these two calls:
ch_gg_hydrographs(WSC_stations = c("09AC001", "09BB001", "09BC001"), daily = TRUE, instantaneous = TRUE, start_date = "2020-01-01", end_date = "2025-09-30", common_dates = TRUE)

and

ch_gg_hydrographs(WSC_stations = c("09AC001", "09BB001", "09BC001"), daily = FALSE, instantaneous = TRUE, start_date = "2020-01-01", end_date = "2025-09-30", common_dates = TRUE)

you can see that all three stations have annual instantaneous peaks available for 2020 through 2023. However, when plotting only instantaneous peaks, the common date handling only retains the last value from the earliest common year and the first value from the last common year.

If you think it makes more sense to plot all values within common years when only instantaneously peaks are plotted, we could pretty easily parse out the common years and set the min_date and max_date. Maybe something like this?

if (common_dates) {
if (daily & !instantaneous) {
common_min_Datetime <- common_daily_min_Datetime
common_max_Datetime <- common_daily_max_Datetime
wsc_daily <- wsc_daily[wsc_daily$Datetime >= common_min_Datetime,]
wsc_daily <- wsc_daily[wsc_daily$Datetime <= common_max_Datetime,]
} else if (!daily & instantaneous) {
common_min_Datetime <- common_inst_min_Datetime
common_max_Datetime <- common_inst_max_Datetime
common_min_Datetime <- as.POSIXct(paste0(format.Date(common_inst_min_Datetime, "%Y"), "-01-01 00:00:00"),
format = "%Y-%m-%d %H:%M:%S")
common_max_Datetime <- as.POSIXct(paste0(format.Date(common_inst_max_Datetime, "%Y"), "-12-31 23:45:00"),
format = "%Y-%m-%d %H:%M:%S")

wsc_inst <- wsc_inst[wsc_inst$Datetime >= common_min_Datetime,]
wsc_inst <- wsc_inst[wsc_inst$Datetime <= common_max_Datetime,]

} else {
common_min_Datetime <- common_daily_min_Datetime
common_max_Datetime <- common_daily_max_Datetime

wsc_daily <- wsc_daily[wsc_daily$Datetime >= common_min_Datetime,]
wsc_daily <- wsc_daily[wsc_daily$Datetime <= common_max_Datetime,]

wsc_inst <- wsc_inst[wsc_inst$Datetime >= common_min_Datetime,]
wsc_inst <- wsc_inst[wsc_inst$Datetime <= common_max_Datetime,]

}
}

One other thought was to have the instantaneous peaks plotted with a different colour other than black when both daily values and instantaneous values are plotted. That might help them show up a little better if plotting a long time series.

On a separate note, is there a better way for me to annotate suggested code changes? Notes directly on the 'Files Changed' tab? Or editing the function .R file and attaching it to this comment?

- fixed vignette
- added colours to gg_hydrographs
- gg_hydrographs now uses common years for instantaneous peaks
@KevinShook
Copy link
Contributor Author

I fixed an embarrassing number of documentation errors, and updated the vignette to use the new ch_model_hydrograph function.
I also added the ability to set the colours of the daily and instantaneous line and points, when a single WSC station is used, and added the suggested code to use common years for annual instantaneous peaks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants